"""
author: Jackson Black
time: 2023-08-14 09-25-57 
"""


def _for(num: int) -> int:
    result = 0
    # range(start,end,step=1) 前闭后开; step默认为1
    for i in range(1, num):
        result += i
    return result


def _while(num: int) -> int:
    result = 0
    while num > 0:
        result += num
        num -= 1
    return result


# 返回最大 <= num 的斐波那契数
def fb(num: int) -> int:
    n1 = n2 = 1
    while n1 <= num and n2 <= num:
        n1 = n1 + n2
        n2 = n1 + n2
    return n1 if n1 < n2 else n2


if __name__ == "__main__":
    print(f'sum(1...10)={_for(11)}')

# if __name__ == "__main__":
#     print(f'sum(1...10)={_while(10)}')
#
# if __name__ == "__main__":
#     print(f'fb(1...100)={fb(100)}')
